//package com.anivia.common.web.config.columnPermission;
//
//
//import cn.hutool.json.JSONUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.alibaba.fastjson.JSONPath;
//import org.springframework.core.MethodParameter;
//import org.springframework.http.MediaType;
//import org.springframework.http.server.ServerHttpRequest;
//import org.springframework.http.server.ServerHttpResponse;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
//
//import java.util.List;
//
///**
// * 后置处理器
// * 处理字段权限
// *
// * @author wangj
// */
//@ControllerAdvice
//public class FieldPermissionAdvice implements ResponseBodyAdvice {
//    @Override
//    public boolean supports(MethodParameter returnType, Class converterType) {
//        return DataFieldContext.get().isOpenFieldPermission();
//    }
//
//    @Override
//    public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//        JSONObject obj = JSONObject.parseObject(JSONUtil.toJsonStr(body));
//
//        List<String> noPermissionExpression = DataFieldContext.get().getNoPermissionExpression();
//        for (String expression : noPermissionExpression) {
//            JSONPath.set(obj, expression, "******");
//        }
//        return obj;
//    }
//
//}